package com.miracle.test;

import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class 字符串操作 {
    public static void main(String[] args) {
        // testSplite();
        testSubstring();
    }

    private static void testSplite(){
        // String str1 = "123, 456 , 78 9,a，b ， c,";
        String str1 = " ,  , ,，，  ";
        String[] split = str1.split(",");
        Arrays.asList(split).stream().forEach(e-> System.out.print(e+"|"));
        System.out.println("");

        String[] split2 = str1.split(",|，");
        List<String> list2 = Arrays.asList(split2).stream().filter(StringUtils::isNotBlank).map(String::trim).collect(Collectors.toList());
        list2.stream().forEach(e-> System.out.print(e+"|"));
        System.out.println("");
        // Arrays.asList(split2).stream().forEach(e-> System.out.print(e+"|"));

    }

    public static void testSubstring(){
        String str1 = "123456789";
        String str2 = "123";
        System.out.println(str1.substring(0,3));
        System.out.println(str2.substring(0,3));

    }
}
